
int techLock;
int techMovieVariable;
int techManagerVariable;

void Tech()
{

	int i;

	/*waits movie theater so that everything will only start when their data has been initialized*/
	/*LockAcquire(initialLock);
	LockRelease(initialLock);*/

	while (1)
	{	
		LockAcquire(techLock);
		/*if movie has not started, wait for manager's signal to start the movie*/
		if(movieStarted==0)
		{
			Write("Tech waiting to start new movie\n",33,1);
			Wait(techManagerVariable, techLock);
		}
		
		/*wait for customers to be seated*/
	
		LockAcquire(techLock);
		while(1)
		{
			
			LockAcquire(seatsFreeLock);
			if(custsSeated!=ticketsTaken)
			{
				LockRelease(seatsFreeLock);
				for(i = 0;i<500;i++)
					Yield();	/*delay loop waiting for customers to get seated*/
			}
			else	/*if customers are seated sstart movie*/
			{
				LockRelease(seatsFreeLock);
				 break;
			}
		}

		/*start the movie*/
		Write("Tech starting movie\n",21,1);
		for (i = 0; i < 300; i++) /*starts the movie for 300 counts while using current thread yield */
		{
			Yield();	/*delay loop to simulate time of movie*/
		}
		Write("Tech ending movie\n",19,1);
		movieStarted=0;
		
		/*tell customers to get out*/
		Broadcast(techMovieVariable, seatsFreeLock);
		seatedPeople=0;
	}
}


